﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Sanchay
{
    public partial class Registers : Form
    {
        public Registers()
        {
            InitializeComponent();
        }

        // Purchase History
        private void pictureBox1_Click(object sender, EventArgs e)
        {

            PurchaseHistory PurchaseHistory;
            if (General.isOpened("PurchaseHistory"))
            {
                PurchaseHistory = (PurchaseHistory)Application.OpenForms["PurchaseHistory"];
                PurchaseHistory.Close();
            }
            PurchaseHistory = new PurchaseHistory();
            PurchaseHistory.Dock = DockStyle.Fill;

            lblStock.Font = new Font(lblStock.Font, FontStyle.Regular);
            lblPurchase.Font = new Font(lblPurchase.Font, FontStyle.Bold);
            lblSales.Font = new Font(lblSales.Font, FontStyle.Regular);

            ShowFormInSplitContainer(PurchaseHistory);
        }

        // Sales History
        private void pictureBoxSales_Click(object sender, EventArgs e)
        {

            SalesHistory SalesHistory;
            if (General.isOpened("SalesHistory"))
            {
                SalesHistory = (SalesHistory)Application.OpenForms["SalesHistory"];
                SalesHistory.Close();
            }
            SalesHistory = new SalesHistory();
            SalesHistory.Dock = DockStyle.Fill;

            lblStock.Font = new Font(lblStock.Font, FontStyle.Regular);
            lblPurchase.Font = new Font(lblPurchase.Font, FontStyle.Regular);
            lblSales.Font = new Font(lblSales.Font, FontStyle.Bold);

            ShowFormInSplitContainer(SalesHistory);
        }

        /// <Method>
        /// Method for showing Forms in Split Container's Lower Panel.
        /// </Method>

        public void ShowFormInSplitContainer(Form sender)
        {
            sender.ControlBox = false;
            sender.FormBorderStyle = FormBorderStyle.None;
            sender.ShowInTaskbar = false;
            sender.TopLevel = false;
            sender.Visible = true;

            splitContainer1.Panel2.Controls.Clear();
            splitContainer1.Panel2.Controls.Add(sender);
        }

        // Stock
        private void pictureBox6_Click(object sender, EventArgs e)
        {
            Stock Stock; ;
            if (General.isOpened("Stock"))
            {
                Stock = (Stock)Application.OpenForms["Stock"];
                Stock.Close();
            }
            Stock = new Stock();
            Stock.Dock = DockStyle.Fill;

            lblStock.Font = new Font(lblStock.Font, FontStyle.Bold);
            lblPurchase.Font = new Font(lblPurchase.Font, FontStyle.Regular);
            lblSales.Font = new Font(lblSales.Font, FontStyle.Regular);

            ShowFormInSplitContainer(Stock);
        }

        private void Registers_Load(object sender, EventArgs e)
        {
           
        }

        public void ActivatePurchase(object sender, EventArgs e)
        {
            pictureBox1_Click(sender, e);
            lblStock.Font = new Font(lblStock.Font, FontStyle.Regular);
            lblPurchase.Font = new Font(lblPurchase.Font, FontStyle.Bold);
            lblSales.Font = new Font(lblSales.Font, FontStyle.Regular);
        }


        public void ActivateSales(object sender, EventArgs e)
        {
            pictureBoxSales_Click(sender, e);
            lblStock.Font = new Font(lblStock.Font, FontStyle.Regular);
            lblPurchase.Font = new Font(lblPurchase.Font, FontStyle.Regular);
            lblSales.Font = new Font(lblSales.Font, FontStyle.Bold);
        }

        public void ActivateStock(object sender, EventArgs e)
        {
            pictureBox6_Click(sender, e);
            lblStock.Font = new Font(lblStock.Font, FontStyle.Bold);
            lblPurchase.Font = new Font(lblPurchase.Font, FontStyle.Regular);
            lblSales.Font = new Font(lblSales.Font, FontStyle.Regular);
        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

       
    }
}
